cmake_minimum_required(VERSION 3.11)
project(HttpLayer)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
	message(STATUS "Running on Linux x86_64 operator system.")
	set(HTTPLAYER_3RD_OUTDIR ${CMAKE_SOURCE_DIR}/3rdpart/outdir/linux)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
	message(STATUS "Running on Linux aarch64 operator system.")
	set(HTTPLAYER_3RD_OUTDIR ${CMAKE_SOURCE_DIR}/3rdpart/outdir/aarch64)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
	message(STATUS "Running on Windows operator system.")
	set(HTTPLAYER_3RD_OUTDIR ${CMAKE_SOURCE_DIR}/3rdpart/outdir/windows)
else ()
	message(STATUS "Running on Unknown operator system.")
endif ()

option(HTTP_LAYER_BUILD_TEST "build tests alongsite the project" ON)
option(HTTP_LAYER_BUILD_EXAMPLES "build examples alongsite the project" ON)
option(HTTP_LAYER_USE_SSL "add support for SSL server" ON)

include(cmake/cmake_find_gtest.cmake)
include(cmake/cmake_find_libevent.cmake)
include(cmake/cmake_find_openssl.cmake)
include(cmake/cmake_find_rapidjson.cmake)
include(cmake/cmake_find_spdlog.cmake)
include(cmake/cmake_find_curl.cmake)
include(CheckIncludeFiles)
include(GNUInstallDirs)

http_layer_find_curl()
http_layer_find_spdlog()

include_directories($<TARGET_PROPERTY:http_layer_gtest_internal,INTERFACE_INCLUDE_DIRECTORIES>)
include_directories($<TARGET_PROPERTY:http_layer_spdlog_internal,INTERFACE_INCLUDE_DIRECTORIES>)
add_subdirectory(src)

if (HTTP_LAYER_BUILD_TEST)
	add_subdirectory(tests)
endif ()

if (HTTP_LAYER_BUILD_EXAMPLES)
	add_subdirectory(examples)
endif ()